package com.example.day1403;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author Lenovo
 */
public class ArrayListDemo {
    public static void main(String[] args) {
        ArrayList<String> array = new ArrayList<>();
        Student s1 = new Student("林青霞", 30);
        Student s2 = new Student("风清扬", 33);
        Student s3 = new Student("张曼玉", 18);
        array.add(String.valueOf(s1));
        array.add(String.valueOf(s2));
        array.add(String.valueOf(s3));
        Iterator<String> it = array.iterator();
        while (it.hasNext()) {
            String s = it.next();
            System.out.println(s.getName() + "," + s.getAge());
        }
        System.out.println("--------------------------");
        for (int i = 0; i < array.size(); i++) {
            Student s = array.get(i);
            System.out.println(s.getName() + "," + s.getAge());
        }
        System.out.println("--------------------------");
        for (Student s : array) {
            System.out.println(s.getName() + "," + s.getAge());
        }
    }
}
